﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Petroleum.DB;
using Petroleum.DB.Model;
using HZH_Controls;
using Petroleum.Model;
using Petroleum.Tool;

namespace Petroleum.UC.Public
{
    public partial class Step2_SSTVD : UserControl, HZH_Controls.Controls.IDataGridViewCustomCell
    {
        private Pressure m_object = null;

        public Step2_SSTVD()
        {
            InitializeComponent();
            //this.attribute = attribute;
            txtInput.InputType = TextInputType.Number;

            txtInput.TextChanged += txt_TextChanged;
        }

        public void SetBindSource(object obj)
        {
            if (obj is Pressure)
                m_object = (Pressure)obj;
        }
        private void txt_TextChanged(object sender, EventArgs e)
        {
            if (m_object != null)
            {
                string value = txtInput.InputText;


                try
                {
                    //int index = value.IndexOf("-");
                    //value = value.Substring(index);
                    Text = value;
                    m_object.SSTVD = decimal.Parse(value);
                    //TVD  = 0-SSTVD+KB
                    m_object.TVD = 0 - m_object.SSTVD + Session.BasicInf.KB;
                }
                catch (Exception)
                {
                    m_object.SSTVD = 0;
                    //TVD  = 0-SSTVD+KB
                    m_object.TVD = 0 - m_object.SSTVD + Session.BasicInf.KB;
                    LogHelper.WriteLog("Step2 == SSTVD输入但转换出错 ");
                }
                //HZH_Controls.Forms.FrmTips.ShowTipsSuccess(this.FindForm(), "选中：" + m_object.TVD);
            }
        }
    }
}
